/*
 * @Description: 集中引入 element 的组件
 * @Date: 2021-04-14 17:48:17 +0800
 * @Author: JackChou
 * @LastEditTime: 2021-04-16 11:25:49 +0800
 * @LastEditors: JackChou
 */

// 创建一个类型
import { App } from '@/model/index'
import 'element-plus/packages/theme-chalk/src/base.scss'
import { ElAlert, ElAvatar, ElBacktop, ElBadge, ElBreadcrumb, ElBreadcrumbItem } from 'element-plus'

import { ElAutocomplete, ElButton } from 'element-plus'

import {
  ElAside,
  ElContainer,
  ElMain,
  ElHeader,
  ElRow,
  ElCol,
  ElMenu,
  ElSubmenu,
  ElMenuItemGroup,
  ElMenuItem,
} from 'element-plus'
const formComponents = [ElAutocomplete, ElButton]
const layout = [ElAside, ElContainer, ElMain, ElHeader, ElRow, ElCol, ElMenu, ElSubmenu, ElMenuItemGroup, ElMenuItem]

const components = [...layout, ...formComponents, ElAlert, ElAvatar, ElBacktop, ElBadge, ElBreadcrumb, ElBreadcrumbItem]
export const setupElement = (app: App, options = { size: 'small' }) => {
  app.config.globalProperties.$ELEMENT = { size: options.size, zIndex: 3000 }
  components.forEach(component => {
    app.component(component.name, component)
  })
  return app
}
